var express = require('express');
var router = express.Router();
var db = require('../public/javascripts/db');

router.get('/', (req, res, next) => {
    console.log(req.query.userId);
    var sql = 'SELECT * FROM history WHERE userId = ?';
    // var sql = 'SELECT * FROM history';
    db.query(sql, req.query.userId, (err, result) => {
        if (err) {
            console.log('[SELECT ERROR]-', err.message);
            return;
        }
        console.log('query item', result[0].id);
        res.send({data: result[0]});
    })
    // res.send('get item');
})

module.exports = router;